#ifndef __CellDB_h__
#define __CellDB_h__

#include <FileSystem/File.h>
#include "Types.h"

class CellDB
{
private:
	File myFile;

	SizeType iBlockSize;
	SizeType iBlockCount;
	unsigned char * ucMap;

	mutable SizeType iFirstFree;

	CellDB(const CellDB&);
	CellDB& operator=(const CellDB&);

	inline SizeType CalcOffset(SizeType iFileNum) const;
	inline void SetBit(SizeType iFileNum, bool value);

	SizeType FindFirstFree() const; 
public:
	CellDB(const char * filePath);
	~CellDB();

	bool IsFull() const;

	SizeType CreateFile(const void * data = NULL, SizeType dataLen = 0);
	SizeType ReadFile(SizeType iFile, void * data, SizeType dataLen, SizeType offset = 0) const;
	SizeType WriteFile(SizeType iFile, const void * data, SizeType dataLen, SizeType offset = 0);
};

#endif

